// components/GBTGridView/GBTGridView.js
var app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    listData: {
      type: JSON,
      value: []
    },
    title: {
      type: String,
      value: "",
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    listData: [],
    download_url: app.globalData.host_url + "gbt/FileManage/download/",
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onItemAdd: function (e) {
      this.triggerEvent('add', e.detail);
    },
    onDetail: function (e) {
      console.log(e);
      this.triggerEvent('detail', e.currentTarget.dataset);
    },
    onCore: function (e) {
      let list = this.data.listData;
      if (list[e.currentTarget.dataset.index].isDisable) {
        if (list[e.currentTarget.dataset.index].isSelected) {
          list[e.currentTarget.dataset.index].isSelected = false;
        } else {
          list[e.currentTarget.dataset.index].isSelected = true;
        }
        this.setData({
          listData: list,
        });
      }
      this.triggerEvent('core', this.data.listData[e.currentTarget.dataset.index]);
    },
  }
})
